<div class="row-content am-cf">
	<div class="row">
		<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
			<div class="widget am-cf">
				
				<div class="widget-head am-cf">
					<div class="widget-title am-fl">新增约束</div>
					<div class="widget-function am-fr">
						<a href="javascript:;" class="am-icon-cog"></a>
					</div>
				</div>
				
				<div class="widget-body am-fr">
					<form class="am-form tpl-form-line-form" id="foreignKeyForm" method="post">
					
						<div class="am-form-group">
							<label for="table" class="am-u-sm-2 am-form-label"><span class="text-red"> *</span>待检表名：</label>
							<div class="am-u-sm-10">
								<input type="text" id="table" class="tpl-form-input" placeholder="请输入待检表名" name="table" /> 
							</div>
						</div>
					
						<div class="am-form-group">
							<label for="field" class="am-u-sm-2 am-form-label"><span class="text-red"> *</span>待检字段名：</label>
							<div class="am-u-sm-10">
								<input type="text" id="field" class="tpl-form-input" placeholder="请输入待检字段名" name="field" /> 
							</div>
						</div>
						
						<div class="am-form-group">
							<label for="referenceTable" class="am-u-sm-2 am-form-label"><span class="text-red"> *</span>参考表名：</label>
							<div class="am-u-sm-10">
								<input type="text" id="referenceTable" class="tpl-form-input" placeholder="请输入参考表名" name="referenceTable" /> 
							</div>
						</div>
						
						<div class="am-form-group">
							<label for="referenceField" class="am-u-sm-2 am-form-label"><span class="text-red"> *</span>参考字段名：</label>
							<div class="am-u-sm-10">
								<input type="text" id="referenceField" class="tpl-form-input" placeholder="请输入参考字段名" name="referenceField" /> 
							</div>
                        </div>
                        
                        <div class="am-form-group">
							<label for="deleteMoment" class="am-u-sm-2 am-form-label">删除时：</label>
							<div class="am-u-sm-10">
								<select data-am-selected="{btnSize: 'sm'}" id="deleteMoment" name="deleteMoment">
									<option value="1" selected="selected">RESTRICT</option>
                                    <option value="2">NO ACTION</option>
                                    <option value="3">CASCADE</option>
									<option value="4">SET NULL</option>
								</select>
							</div>
                        </div>
                        
                        <div class="am-form-group">
							<label for="updateMoment" class="am-u-sm-2 am-form-label">更新时：</label>
							<div class="am-u-sm-10">
								<select data-am-selected="{btnSize: 'sm'}" id="updateMoment" name="updateMoment">
									<option value="1" selected="selected">RESTRICT</option>
                                    <option value="2">NO ACTION</option>
                                    <option value="3">CASCADE</option>
									<option value="4">SET NULL</option>
								</select>
							</div>
						</div>

						<div class="am-form-group">
							<div class="am-u-sm-10 am-u-sm-push-2">
								<button type="button" onclick="javascript:$('#foreignKeyForm').submit();"
									class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
									
								<button type="button" onclick="loadPage('foreignKey/listUI')"
									class="am-btn am-btn-success tpl-btn-bg-color-success ">返回</button>
							</div>
						</div>
						
					</form>
				</div>	
			</div>
		</div>
	</div>
</div>

<script th:inline="javascript">
<![CDATA[

    validateUserForm();

	function validateUserForm(){
		
	    $('#foreignKeyForm').validate({
	        errorElement: 'span',
	        errorClass: 'am-icon-times',
	        focusInvalid: true,
	        onkeyup: false,
	        ignore: "",
	        rules: {
	        	table: {
	                required: true,
	                maxlength: 50
	            },
	        	field: {
	        		required: true,
	        		maxlength: 100
	            },
	            referenceTable: {
                    required: true,
	            	maxlength: 50
	            },
	            referenceField: {
	            	required: true,
					maxlength: 100
	            }
	        },
	        messages: {
	        	table: {
	                required: "请填写待检表名"
	            },
	            field: {
	                required: "请填写待检字段名"
	            },
	            referenceTable: {
	            	required: "请填写参考表名"
	            },
	            referenceField: {
	            	required: "请填写参考字段名"
	            }
	        },
	        submitHandler: function(form) {
	        	commit('foreignKeyForm', 'foreignKey/save', 'foreignKey/listUI');
	        }
	    });
	}
]]>
</script>